/*
 * Copyright 2015 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 * 2023.4.23 SkFontMgr on ohos.
 *           Copyright (c) 2023 Huawei Device Co., Ltd. All rights reserved.
 */

#ifndef SKFONTMGR_OHOS_H
#define SKFONTMGR_OHOS_H

#include "src/core/SkFontDescriptor.h"
#include "include/core/SkFontMgr.h"
#include "modules/skparagraph/include/FontCollection.h"
#include <native_drawing/drawing_font_mgr.h>


class SkFontMgr_OHOS : public SkFontMgr {
public:
    explicit SkFontMgr_OHOS(const char* path = nullptr);
    virtual ~SkFontMgr_OHOS() override;
protected:
    int onCountFamilies() const override;
    void onGetFamilyName(int index, SkString* familyName) const override;
    sk_sp<SkFontStyleSet> onCreateStyleSet(int index)const override;

    sk_sp<SkFontStyleSet> onMatchFamily(const char familyName[]) const override;

    sk_sp<SkTypeface> onMatchFamilyStyle(const char familyName[],
                                           const SkFontStyle& style) const override;
    sk_sp<SkTypeface> onMatchFamilyStyleCharacter(const char familyName[], const SkFontStyle& style,
                                                    const char* bcp47[], int bcp47Count,
                                                    SkUnichar character) const override;


    sk_sp<SkTypeface> onMakeFromData(sk_sp<SkData> data, int ttcIndex) const override;
    sk_sp<SkTypeface> onMakeFromStreamIndex(std::unique_ptr<SkStreamAsset> stream,
                                                    int ttcIndex) const override;
    sk_sp<SkTypeface> onMakeFromStreamArgs(std::unique_ptr<SkStreamAsset> stream,
                                                   const SkFontArguments& args) const override;
    sk_sp<SkTypeface> onMakeFromFile(const char path[], int ttcIndex) const override;

    sk_sp<SkTypeface> onLegacyMakeTypeface(const char familyName[], SkFontStyle style) const override;

    static sk_sp<SkFontMgr> RefDefault();
    static sk_sp<SkFontMgr> RefEmpty();

private:
    OH_Drawing_FontMgr *fFontMgrOHOS = nullptr;
// private:
//     std::shared_ptr<FontConfig_OHOS> fontConfig = nullptr; // the pointer of FontConfig_OHOS
//     SkFontScanner_FreeType fontScanner; // the scanner to parse a font file
//     int familyCount = 0; // the count of font style sets in generic family list
//
//     int compareLangs(const SkString& langs, const char* bcp47[], int bcp47Count, const int tps[]) const;
//     sk_sp<SkTypeface> makeTypeface(std::unique_ptr<SkStreamAsset> stream,
//                                     const SkFontArguments& args, const char path[]) const;
//     sk_sp<SkTypeface> findTypeface(const FallbackSetPos& fallbackItem, const SkFontStyle& style,
//                              const char* bcp47[], int bcp47Count,
//                              SkUnichar character) const;
};


#endif /* SKFONTMGR_OHOS_H */
